package org.filecollector.msgcontroller.requests;

import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import lombok.NonNull;

public record RequestMessage(
        @SerializedName("method") @NonNull RESTMethod method,
        @SerializedName("uri") @NonNull String uri,
        @SerializedName("id") Long id,
        @SerializedName("buf_size") int bufSize,
        @SerializedName("data") String data
) {
    static Gson gsonParser = new Gson();

    public static RequestMessage deserialize(String json) {
        return gsonParser.fromJson(json, RequestMessage.class);
    }

    public String serialize() {
        return gsonParser.toJson(this);
    }
}
